# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=gopherus
pkgver=33.90a2fd5
pkgrel=3
pkgdesc='Tool generates gopher link for exploiting SSRF and gaining RCE in various servers.'
groups=('blackarch' 'blackarch-webapp' 'blackarch-exploitation')
arch=('any')
url='https://github.com/tarunkant/Gopherus'
license=('MIT')
depends=('python2' 'python2-argparse' 'python2-requests')
makedepends=('git')
source=("$pkgname::git+https://github.com/tarunkant/Gopherus.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm LICENSE README.md install.sh

  cp -a --no-preserve=ownership * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 $pkgname.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

